package com.store.practice.controller;

import com.store.practice.common.api.CommonResult;
import com.store.practice.model.AppAccount;
import com.store.practice.service.StaffUserDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/store")
@Api(tags = "LoginController",description = "用户登录")
public class LoginController {
    @Autowired
    private StaffUserDetailsService userDetailsService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public CommonResult login(Long num,String password){
        Map result = userDetailsService.login(num, password);
        if (result!=null){
            return CommonResult.success(result);
        }
        return CommonResult.failed();
    }
}
